<?php

namespace app\web\controller;

use app\web\service\CarService;

// 专车控制器
class CarController extends CommonController
{
    public function initialize()
    {
//        $this->noCheckTokenAction = ["getOrderData"];
        parent::initialize();
    }

    // 获取下订单页的数据
    public function getOrderData(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getOrderData();
        return $this->return_result($this->returnData);
    }

    // 获取下订单页的数据
    public function getOrderSure(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getOrderSure($this->app->request->userLoginData["id"]);
        return $this->return_result($this->returnData);
    }

    // 提交订单
    public function toSubmitOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toSubmitOrder($this->app->request->userLoginData["id"], $this->app->request->userLoginData["openid"]);
        return $this->return_result($this->returnData);
    }
}
